<template>
	<view class="wrapper">
		<form @submit="formSubmit">
			
		<view class="content">
			
			<view class="title-item">
				<view class="title">反馈标题</view>
				
				<view class="title-inp">
					<input placeholder="请输入您要反馈的标题"  name="title" placeholder-class="plass" />
				</view>
			</view>
			
			<view class="order-remark">
				<view class="-remark-title">反馈内容</view>
				
				<view class="-remark-text">
					<textarea placeholder="请输入您想要反馈的内容"  name="content" placeholder-class="plass"></textarea>
				</view>
			</view>
			
			<view class="order-remark">
				<view class="-remark-title">上传图片</view>
				
				<view class="tui-box-upload">
					<!-- <tui-upload :serverUrl="serverUrl"  @complete="result" @remove="remove"></tui-upload> -->
					<u-upload :action="serverUrl" @on-uploaded="onUploaded" name="headimg" :file-list="fileList" ></u-upload>
				</view>
			</view>
			
		</view>
		
		<button class="submit-btn" formType="submit" >发布</button>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imageData: [],
				//上传地址
				serverUrl: this.$websiteUrl + '/index.php/Store/User/upload_image',
				fileList: []
				// limit: 1,
				
				
			}
		},
		onLoad (options) {
			
		},
		onShow() {
			
		},
		mounted() {
			
		},
		methods:{
			result: function(e) {
				console.log(e.tuId)
				this.imageData = e.tuId;
			},
			remove: function(e) {
				//移除图片
				let index = e.index
			},
			onUploaded(lists) {
				console.log(lists,this.imageData)
				this.imageData = []
				lists.forEach((item,index)=>{
					this.imageData.push(item.response.data.headimg)
				})
			},
			//选择支付方式
			changePayType(type) {
				this.payType = type;
			},
			back() {
				uni.navigateBack({
					delta: 1
				});
			},
			
			//发布/编辑二手车
			formSubmit:function(e){
					var that = this;
					var data = e.detail.value;
					var store_id = uni.getStorageSync('store_id');
					data.car_image = that.imageData.join(',');
					data.store_id = store_id;
				
					if(data.title == ''){
						that.$api.errorMsg('请填写标题');return;
					}
					if(data.content == ''){
						that.$api.errorMsg('请填写内容');return;
					}
							that.$api.WaitModel('正在提交...');
							uni.request({
								url: that.$websiteUrl + '/index.php/Store/User/Feedback.html', 
								data: data,
								method:'POST',
								dataType:'json',
								header: {'content-type' : 'application/x-www-form-urlencoded'},
								success: (resa) => {
									that.$api.HideWaitModel();
									var one = resa.data;
									if(one.status == 200){
										that.$api.successMsg(one.message);
										setTimeout(function () {
											uni.navigateBack({
											    delta: 1
											});
										}, 2000);
									
									}else{
										that.$api.errorMsg(one.message);
									}
								},
								fail: (resa) => {
									that.$api.HideWaitModel();
									that.$api.errorMsg('网络连接超时，请检查您的网络');
								}
							})
			},
			
		}
	}
</script>

<style lang="scss">
	page {
		background: #f7f7f7;
	}
	.wrapper {
		padding-bottom: 30upx;
	}
	.content {
		
		.title-item {
			padding: 0 30upx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			background: #fff;
			line-height: 75upx;
			.title {
				font-size: 26upx;
				font-weight: bold;
				color: #333;
			}
			.title-inp {
				width: 465upx;
				height: 75upx;
				text-align: right;
				input {
					width: 100%;
					height: 100%;
					font-size: 26upx;
					color: #333;
				}
			}
		}
	}
	.wrapper {
		image {
			display: block;
			width: 100%;
			height: 100%;
		}
		.content {
			
			.order-remark {
				padding: 30upx 24upx;
				background: #fff;
				.-remark-title {
					font-size: 26upx;
					font-weight: bold;
					color: #333;
					line-height: 75upx;
				}
				.-remark-text {
					padding: 23upx 25upx;
					width: 100%;
					height: 300upx;
					border-radius: 10upx;
					border: 1px solid #edf0f2;
					box-sizing: border-box;
					textarea {
						width: 100%;
						height: 100%;
						font-size: 26upx;
						color: #333;
					}
				}
			}
		}
	}
	.plass {
		font-size: 26upx;
		color: #ccc;
	}
	.submit-btn {
		margin: 135upx auto;
		width: 540upx;
		height: 80upx;
		background: #f70000;
		border-radius: 40upx;
		font-size: 28upx;
		letter-spacing: 2px;
		color: #fff;
		text-align: center;
		line-height: 80upx;
	}
	
	.order-remark /deep/ .tui-image-item:nth-child(3n) {
		margin-right: 0 !important;
	}
</style>
